﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpCart.BusinessObjects
{
    public abstract class ProductBase
    {
        #region Declarations
        internal  Data.SharpDb Db;
        internal  Data.ProductBase DataProduct;
        protected bool IsNew;
        #endregion

        #region Properties
        public int ID
        {
            get
            {
                return DataProduct.ID;
            }
            set
            {
                DataProduct.ID = value;
            }
        }
        public string Title
        {
            get
            {
                return DataProduct.Title;
            }
            set
            {
                DataProduct.Title = value;
            }
        }
        public bool IsActive
        {
            get
            {
                return DataProduct.IsActive;
            }
            set
            {
                DataProduct.IsActive = value;
            }
        }
        public string Description
        {
            get
            {
                return DataProduct.Description;
            }
            set
            {
                DataProduct.Description = value;
            }
        }
        public abstract decimal Price
        {
            get;
            set;
        }
        public abstract int Quantity
        {
            get;
            set;
        }
        #endregion

        #region Instance Methods

        /// <summary>
        /// Saves the current state of the SimpleProduct to the database.
        /// </summary>
        public virtual void Save()
        {
            if (IsNew)
            {
                Db.AddToProductBase(DataProduct);
            }
            Db.SaveChanges();
            IsNew = false;
        }
        #endregion

    }
}
